package com.sk.gzwater.adapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.sk.gzewop.R;

import android.content.Context;
import android.database.DataSetObserver;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListAdapter;
import android.widget.TextView;

public class JishilvAdapter implements ListAdapter  {
	private Context context;
	private ArrayList<HashMap<String, String>> dataList;
	public JishilvAdapter (Context context,ArrayList<HashMap<String, String>> dataList){
		this.context = context;
		this.dataList = dataList;
	}
	
	@Override
	public void registerDataSetObserver(DataSetObserver observer) {		
	}

	@Override
	public void unregisterDataSetObserver(DataSetObserver observer) {
	}

	@Override
	public int getCount() {
		return dataList.size();
	}

	@Override
	public Object getItem(int position) {
		return dataList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public boolean hasStableIds() {
		return true;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = LayoutInflater.from(context).inflate(R.layout.jishilv_adapter, null);
		TextView tv1 = (TextView)view.findViewById(R.id.tv_jishilv_plantname);
		TextView tv2 = (TextView)view.findViewById(R.id.tv_jishilv_hysb);
		TextView tv3 = (TextView)view.findViewById(R.id.tv_jishilv_hysh);
		TextView tv4 = (TextView)view.findViewById(R.id.tv_jishilv_scsb);
		TextView tv5 = (TextView)view.findViewById(R.id.tv_jishilv_scsh);
		tv1.setText(dataList.get(position).get("plantName"));
		tv2.setText(dataList.get(position).get("hysb")+"%");
		tv3.setText(dataList.get(position).get("hysh")+"%");
		tv4.setText(dataList.get(position).get("scsb")+"%");
		tv5.setText(dataList.get(position).get("scsh")+"%");		
		return view;
	}

	@Override
	public int getItemViewType(int position) {
		return 0;
	}

	@Override
	public int getViewTypeCount() {
		return 1;
	}

	@Override
	public boolean isEmpty() {
		return false;
	}

	@Override
	public boolean areAllItemsEnabled() {
		return true;
	}

	@Override
	public boolean isEnabled(int position) {
		return true;
	}

}
